package com.company.app.events;

import com.company.app.components.DialogComponent;
import com.company.app.constants.Sentence;
import com.company.app.entities.FrameValueObject;
import com.company.app.entities.ImageValueObject;
import com.company.app.services.PicsListHandler;

public class PicsCollectListener {
  public void coreListener(FrameValueObject obj) {
    PicsListHandler p = new PicsListHandler();
    String[] array = null;
    ImageValueObject imgJO = obj.getImageValObj();

    if (imgJO != null) {
      array = imgJO.getCurrentPathsArray();
      p.showImageList(array, obj);
    } else {
      System.out.println(this.getClass() + ":coreListener:No image opened");
      warnByJudge(array, obj);
    }
  }

  public void warnByJudge(String[] imagesUrlArray, FrameValueObject obj) {
    if (imagesUrlArray == null || imagesUrlArray.length == 0) {
      DialogComponent dialog = new DialogComponent();

      dialog.getCustomDialog(Sentence.BUTTON_HINT_TEXT, null, Sentence.WARN_DIALOG_TITLE, Sentence.WARN_DIALOG_MSG);
      return;
    }
  }
}